package cn.itenzo.controller;

import cn.itenzo.good.model.Good;
import cn.itenzo.good.service.GoodService;
import cn.itenzo.vo.ReqParam;
import cn.itenzo.vo.RetList;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/5/30 0030.
 */
@Controller
@RequestMapping(value = "good")
public class GoodController {

    @Reference
    private GoodService goodService;


    @ResponseBody
    @RequestMapping(value = "l")
    public RetList GoodList(Long id, @RequestBody ReqParam param) {
        Good good = new Good();
        int page = param.getPage();
        good.setGoodStoreId(id);
        PageInfo<Good> goodItemPageInfo =  goodService.queryPageByStrore(good, page, param.getLimit(), param.getOrderCluse());
        RetList retList = new RetList(goodItemPageInfo.getTotal(),goodItemPageInfo.getList());


        return retList;
    }
}
